<?php
/**
 * Created by PhpStorm.
 * User: 17208
 * Date: 2019/7/5
 * Time: 15:42
 */

namespace app\api\timer;
use think\Exception;
use think\facade\Log;
use Swoole\Process;

class Timer1s
{
    public $works=[];
    public function run(){
        try {
            // 在线匹配
            $Matching = new Matching();
            $this->run_timer($Matching);

        } catch (Exception $e) {
            Log::info("运行异常：".$e->getMessage());
        }
    }
    private function run_timer($timer){
        $process = new Process(function(Process $worker)use($timer){
            $timer->run();
        }, false, false);
        $pid=$process->start();
        // $this->works[$timer]=$pid;
        return $pid;
    }
}